
import { _decorator, Component, Node, EventTouch } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Control')
export class Control extends Component {
    @property({type: [Node]})
    public actionButtons: Node[] = [];

    onLoad(){
        for(let button of this.actionButtons){
            button.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
            button.on(Node.EventType.TOUCH_END, this.onTouchStart, this);
            button.on(Node.EventType.TOUCH_CANCEL, this.onTouchStart, this);
        }
    }

    start () {
        // [3]
    }

    // update (deltaTime: number) {
    //     // [4]
    // }

    onTouchStart(event: EventTouch){
        this.node.emit(this.node.name);
    }

    onTouchEnd(event:EventTouch){

    }
}
